package cn.thoughtworks.school.notifications.impl;

import cn.thoughtworks.school.notifications.NotificationFactory;
import cn.thoughtworks.school.notifications.Properties;
import cn.thoughtworks.school.services.ProgramCenterService;
import cn.thoughtworks.school.services.UserCenterService;

import java.util.Map;

public class StudentModifyAssignmentNotification extends NotificationFactory {

  public StudentModifyAssignmentNotification(Map data, Properties properties, UserCenterService userCenterService, ProgramCenterService programCenterService) {
    super(data, properties, userCenterService, programCenterService);
    String tutorIds = getMyTutorIds();
    data.put("receiverId", tutorIds);
    data.put("studentId", data.get("senderId"));
  }

  @Override
  protected String getMessage() {
    StringBuilder message = new StringBuilder();
    Map sender = getUser(Long.parseLong(data.get("senderId").toString()));
    Map program = getProgram();
    Map assignment = getAssignment(data.get("assignmentId").toString());
    message.append(program.get("title"))
      .append(" 训练营的学员 ")
      .append(getUserName(sender))
      .append(" 完成了 ")
      .append(assignment.get("title"))
      .append(" 作业 ，快去看看吧！ ");

    return message.toString();
  }

  @Override
  protected String getMessage_en() {
    StringBuilder message = new StringBuilder();
    Map sender = getUser(Long.parseLong(data.get("senderId").toString()));
    Map program = getProgram();
    Map assignment = getAssignment(data.get("assignmentId").toString());
    message.append(program.get("title"))
      .append(" : ")
      .append(getUserName(sender))
      .append(" finished ")
      .append(assignment.get("title"))
      .append(" assignment.");

    return message.toString();
  }
}
